<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <script src="../build/react.development.js"></script>
    <script src="../build/react-dom.development.js"></script>
    <script src="../build/babel.min.js"></script>
    <script src="../build/prop-types.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script type="text/babel">

      var data = '123',data2='世界和平';

    // 标签上的属性数据传入到 component函数内
    
      class MyTitle extends React.Component {
        static propTypes = {
        // 如果这里传递一个123数值型,类型不为string 就会在console中报错      
          title: PropTypes.string.isRequired,
        }
        render() {
          return <h1> {this.props.title} </h1>;
        }
      }

      class ThatTitle extends React.Component {
          static propTypes ={
             h2 : PropTypes.string.isRequired,
          }

          render(){
            return <h2>{this.props.h2}</h2>
          }

      }

      ReactDOM.render(
        <div>
        <MyTitle title={data} />
        <ThatTitle h2={data2}/>
      </div>
        ,
        document.getElementById('example')
      );

    </script>
  </body>
</html>

